package com.tianji.learning.config;

import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.plugins.handler.TableNameHandler;
import com.baomidou.mybatisplus.extension.plugins.inner.DynamicTableNameInnerInterceptor;
import com.tianji.learning.utils.TableInfoContext;
import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.context.annotation.Configuration;

import java.util.HashMap;
import java.util.Map;

/**
 * @description
 * @author: ZXX-挚爱
 * @time: 2023/8/2 1:12
 */
@Configuration
public class MybatisConfiguration {
    public DynamicTableNameInnerInterceptor dynamicTableNameInnerInterceptor(){
        Map<String, TableNameHandler> map = new HashMap<>(1);
        map.put("points_board",(sql, TableName)-> TableInfoContext.getInfo());
        return new DynamicTableNameInnerInterceptor(map);
    }
}
